package com.plsjavaweb.dao.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import org.apache.log4j.Logger;

import com.plsjavaweb.dao.DAOFactory;
import com.plsjavaweb.logging.LoggingConstants;
import com.plsjavaweb.pojo.AccountPOJO;
import com.plsjavaweb.pojo.SeatAllocationPOJO;

public class CSSeatAllocationMapper implements Mapper<SeatAllocationPOJO> {
	Logger log = Logger.getLogger(DAOFactory.class);

	@Override
	public List<SeatAllocationPOJO> MapList(ResultSet rs) throws SQLException {
		log.info(LoggingConstants.entryMessage);
		log.info(LoggingConstants.returnedMessage);
		log.info("null return");
		return null;
	}

	@Override
	public SeatAllocationPOJO MapObject(ResultSet rs) throws SQLException {
		log.info(LoggingConstants.entryMessage);
		
		
		SeatAllocationPOJO report = new SeatAllocationPOJO();
		while (rs.next()) {			
			String seatCode = rs.getString("seat_type_code");
			if (seatCode.equalsIgnoreCase("ALLOCATED")) {
				report.setSeatAllocated(rs.getInt("seat_count"));
			}else if (seatCode.equalsIgnoreCase("RESERVED")) {
				report.setSeatReserved(rs.getInt("seat_count"));
			}else if (seatCode.equalsIgnoreCase("VACANT")) {
				report.setSeatVacant(rs.getInt("seat_count"));
			}			
		}
		log.info(LoggingConstants.returnedMessage);
		return report;
	}

}
